﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class PhuKienDT : System.Web.UI.Page
{
    DataTable dt = new DataTable();
    KetNoi obj = new KetNoi();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadLoaiPhuKien();
        }
        LoadTaiNgheDay();
        LoadTaiNgheBlueTooth();
        LoadBaoDaTui();
        LoadNapLung();
        MiengDanManHinh();
        TheNho();
        ThietBiKetNoi();
        Sac();
        Pin();
    }
    protected void LoadLoaiPhuKien()
    {
        dt = obj.loadDataTable("Select * from LoaiPhuKien");
        drploaipk.DataTextField = "TenLoaiPK";
        drploaipk.DataValueField = "MaLoaiPK";
        drploaipk.DataSource = dt;
        drploaipk.DataBind();
    }
    protected void LoadTaiNgheDay()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='001'");
        Repeater5.DataSource = dt;
        Repeater5.DataBind();
    }

    protected void LoadTaiNgheBlueTooth()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='002'");
        Repeater6.DataSource = dt;
        Repeater6.DataBind();
    }

    protected void LoadBaoDaTui()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='004'");
        Repeater7.DataSource = dt;
        Repeater7.DataBind();
    }

    protected void LoadNapLung()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='005'");
        Repeater8.DataSource = dt;
        Repeater8.DataBind();
    }

    protected void MiengDanManHinh()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='006'");
        Repeater9.DataSource = dt;
        Repeater9.DataBind();
    }

    protected void TheNho()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='007'");
        Repeater10.DataSource = dt;
        Repeater10.DataBind();
    }

    protected void ThietBiKetNoi()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='008'");
        Repeater11.DataSource = dt;
        Repeater11.DataBind();
    }

    protected void Sac()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='009'");
        Repeater12.DataSource = dt;
        Repeater12.DataBind();
    }

    protected void Pin()
    {
        dt = obj.loadDataTable("Select * from PhuKienDienThoai Where MaLoaiPK='010'");
        Repeater13.DataSource = dt;
        Repeater13.DataBind();
    }

    protected void btnTim_Click(object sender, EventArgs e)
    {
        
        Response.Redirect("TimKiemPhuKien.aspx?MaLoaiPK=" + drploaipk.SelectedValue.ToString() + "&giatu=" + drpgiatu.SelectedValue.ToString() + "&giaden=" + drpgiaden.SelectedValue.ToString());
    }
}
